<!DOCTYPE html>
<html>
<head>
	<title>菜单添加</title>
	<link rel="stylesheet" type="text/css" href="/static/public/layui/css/layui.css">
	<script type="text/javascript" src="/static/public/layui/layui.js"></script>
</head>
<body style="padding: 10px;">
	<form class="layui-form">
		@csrf
		<input type="hidden" name="pid" value="{{$pid}}">
		<div class="layui-form-item">
			<label class="layui-form-label">菜单名称</label>
			<div class="layui-input-block">
				<input type="text" class="layui-input" name="title">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">排序</label>
			<div class="layui-input-block">
				<input type="number" class="layui-input" name="ord">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">控制器</label>
			<div class="layui-input-block">
				<input type="text" class="layui-input" name="controller">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">方法</label>
			<div class="layui-input-block">
				<input type="text" class="layui-input" name="action">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">是否隐藏</label>
			<div class="layui-input-block">
				<input type="checkbox" name="ishidden" value="1" title="隐藏" lay-skin="primary">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">状态</label>
			<div class="layui-input-block">
				<input type="checkbox" name="status" value="1" title="禁用" lay-skin="primary">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button type="button" class="layui-btn" onclick="save()">保存</button>
			</div>
		</div>
	</form>
</body>
</html>
<script type="text/javascript">
	layui.use(['layer','form'],function(){
		layer = layui.layer;
		form = layui.form;
		$ = layui.jquery;
	});

	function save(){
		var title = $.trim($('input[name="title"]').val());
		if(title==''){
			return layer.alert('请填写菜单名称',{icon:2});
		}
		$.post('/admin/menus/save',$('form').serialize(),function(res){
			if(res.code>0){
				return layer.alert(res.msg,{icon:2});
			}
			layer.msg(res.msg);
			setTimeout(function(){parent.window.location.reload();},1000);
		},'json');
	}
</script>
